package com.feifan.monthhelper.ui;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;

import com.blankj.utilcode.util.StringUtils;
import com.blankj.utilcode.util.ToastUtils;
import com.feifan.monthhelper.R;
import com.feifan.monthhelper.bao.ToastUtil;
import com.feifan.monthhelper.ui.base.BaseActivity;
import com.feifan.monthhelper.wedget.DoubleClickListener;

import java.util.concurrent.TimeUnit;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import io.reactivex.Observable;
import io.reactivex.Scheduler;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
import io.reactivex.functions.Consumer;
import io.reactivex.schedulers.Schedulers;

public class FeedbackActivity extends BaseActivity {

    @BindView(R.id.iv_back)
    ImageView ivBack;
    @BindView(R.id.et_of_content)
    EditText etOfContent;
    @BindView(R.id.tv_submit)
    TextView tvSubmit;

    @Override
    protected void initData() {

    }

    @Override
    public void initView() {
        ivBack.setOnClickListener(new DoubleClickListener() {
            @Override
            public void doOnClick(View view) {
                finish();
            }
        });
        tvSubmit.setOnClickListener(new DoubleClickListener() {
            @Override
            public void doOnClick(View view) {
                if(StringUtils.isEmpty(etOfContent.getText().toString().trim())) {
                    ToastUtils.showShort(R.string.content_is_null);
                    return;
                }
                Disposable disposable  = Observable.timer(2, TimeUnit.SECONDS)
                        .doOnSubscribe(o -> showLoadingDialog(""))
                        .doOnNext(a -> dismisDialog())
                        .subscribeOn(AndroidSchedulers.mainThread())
                        .observeOn(Schedulers.io())
                        .subscribe(aLong -> {
                            ToastUtils.showShort(R.string.feedback_successed);
                            finish();
                        });
                addDisposable(disposable);
            }
        });
    }

    @Override
    protected int setContentLayout() {
        return  R.layout.activity_feedback;
    }

}
